/**
 *====================================================
 * 文件名称: FinanceSignatureInfoServiceImpl.java
 * 修订记录：
 * No    日期				作者(操作:具体内容)
 * 1.    2015年09月23日	chenxy(创建:创建文件)
 *====================================================
 * 类描述：(说明未实现或其它不应生成javadoc的内容)
 */
package com.yuexunit.finance.project.service;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

import com.yuexunit.finance.member.entity.SignatureInfoEntity;
import com.yuexunit.inject.annotation.Implements;
import com.yuexunit.persist.PersistUtil;
import com.yuexunit.persist.annotation.Transactional;

/**
 * @ClassName: FinanceSignatureInfoServiceImpl
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @author chenxy
 * @date 2015年09月23日 18:56:17
 */
@Implements(FinanceSignatureInfoService.class)
public class FinanceSignatureInfoServiceImpl implements FinanceSignatureInfoService {

	
	@Override
	@Transactional
	public Long createSignatureInfoEntity(SignatureInfoEntity entity) {
		PersistUtil.insert(entity);
		return entity.getId();
	}

	@Override
	public List<SignatureInfoEntity> inquireFinanceSignatureInfoEntityList() {
		DetachedCriteria criteria = DetachedCriteria.forClass(SignatureInfoEntity.class);
		criteria.addOrder(Order.desc("createDateTime"));
		return PersistUtil.get(criteria);
	}

	@Override
	public SignatureInfoEntity inquireFinanceSignatureInfoEntity(String fileUuid) {
		DetachedCriteria criteria = DetachedCriteria.forClass(SignatureInfoEntity.class);
		criteria.add(Restrictions.eq("fileUuid", fileUuid));
		criteria.addOrder(Order.desc("createDateTime"));
		List<SignatureInfoEntity> list=PersistUtil.get(criteria);
		return list!=null&&list.size()>0?list.get(0):null;
	}

	@Override
	public void updateSignatureInfoEntity(SignatureInfoEntity entity) {
		PersistUtil.update(entity);
	}

	@Override
	public List<SignatureInfoEntity> inquireFinanceSignatureByFinanceIdList(
			Long financeId) {
		DetachedCriteria criteria = DetachedCriteria.forClass(SignatureInfoEntity.class);
		criteria.add(Restrictions.eq("joinId", financeId));
		criteria.addOrder(Order.desc("createDateTime"));
		return PersistUtil.get(criteria);
	}

	@Override
	public void deleteSignatureInfoEntity(Long financeId) {
		List<SignatureInfoEntity> list=inquireFinanceSignatureByFinanceIdList(financeId);
		if(list!=null && list.size()>0)
		{
			PersistUtil.delete(list.get(0));
		}
	}
	
}
